<?php

namespace app\index\controller;

use app\common\CommonController;
use app\index\service\ImportexportService;
use app\index\service\NewskuService;

class Newsku extends CommonController
{
    public function __construct()
    {
        parent::__construct();
    }

    //获取新品sku列表
    public function index()
    {
        $res = NewskuService::getNewSkuList($this->param);
        exitJson($res);
    }

    //导出新品sku列表
    public function exportNewSku()
    {
        $this->param['actionAsync'] = "\app\index\service\NewskuService::getNewSkuList";
        $result = ImportexportService::exportLogic($this->param, 1);
        exitJson($result);
    }
    //获取分类
    public function getCate()
    {
        $data=NewskuService::getCate($this->param);
        returnJson(1,'',$data);
    }
    //编辑新品sku
    public function editSku(){
        checkParam($this->param, ['e'], 'sku');
        NewskuService::editSku($this->param);
        returnJson();
    }
    //编辑销售状态
    public function editSkuSaleStatus(){
        checkParam($this->param, ['e'], 'sku');
        exitJson(NewskuService::editSkuSaleStatus($this->param));
    }
    //上传新品sku
    public function uploadAdd(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\NewskuService::uploadAdd";
        $result = ImportexportService::importTask($param, 3,2);
        exitJson($result);
    }
    //上传更新sku信息
    public function uploadUpdate(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\NewskuService::uploadUpdate";
        $result = ImportexportService::importTask($param, 4,2);
        exitJson($result);
    }
    //上传更新sku信息
    public function uploadUpdateSaleStatus(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\NewskuService::uploadUpdateSaleStatus";
        $result = ImportexportService::importTask($param, 27,2);
        exitJson($result);
    }
    //启用禁用
    public function uploadUpdateStatus(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\NewskuService::uploadUpdateStatus";
        $result = ImportexportService::importTask($param, 28,2);
        exitJson($result);
    }
    //更新参考价
    public function uploadUpdatePrice(){
        $param = $this->param;
        $param['actionAsync'] = "\app\index\service\NewskuService::uploadUpdatePrice";
        $result = ImportexportService::importTask($param, 51,2);
        exitJson($result);
    }
    //编辑参考价
    public function editSkuPrice(){
        checkParam($this->param, ['e'], 'sku');
        exitJson(NewskuService::editSkuPrice($this->param));
    }
}